# 冒泡排序

l=[9,8,7,6,5,4,3,2,1]
conut1=0
conut2=0
for i in range(len(l)-1):
    for j in range(i+1,len(l)):
        conut1+=1
        if l[j]<l[i]:
            conut2+=1
            temp=l[i]
            l[i]=l[j]
            l[j]=temp
    print(f'{i}轮,{l}')
print(l)
print(f'比较{conut1}次,交换{conut2}次')


# count=0
# count1=0
#
# for i in range(len(l)-1):
#     min=i
#     for j in range(i+1,len(l)):
#         count+=1
#         if l[j]<l[min]:
#             min=j
#     if min!=i:
#         count1+=1
#         temp=l[i]
#         l[i]=l[j]
#         l[j]=temp
#     print(f'第{i}轮，交换结果为{l}')
# print(f'比较{count}次，交换{count1}次')